package com.gq.rising;

import com.gq.rising.common.DbSource;
import com.gq.rising.core.InitiFace;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class RisingApplication {

    //单例DbSource
    @Bean
    public DbSource dbSource(){
        return new DbSource();
    }

    @Bean
    public InitiFace initiFace(){
        return new InitiFace();
    }

    public static void main(String[] args) {
        // 分线程启动JFrame程序页面
//        SwingUtilities.invokeLater(()->{
//            new InitiFace().init();
//        });
//        SpringApplication.run(RisingApplication.class, args);

        SpringApplicationBuilder builder = new SpringApplicationBuilder(RisingApplication.class);
        //解决初始化程序界面时HeadlessException异常，/**-Djava.awt.headless=false */
        ConfigurableApplicationContext context = builder.headless(false).run(args);
        System.err.println("DbSource Init: "+context.getBean(DbSource.class));
        //初始化程序界面
        context.getBean(InitiFace.class).init();
    }

}
